<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - queue_sort_abstract.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2003  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#undef</font> DLIB_QUEUE_SORt_ABSTRACT_
<font color='#0000FF'>#ifdef</font> DLIB_QUEUE_SORt_ABSTRACT_


<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='queue_kernel_abstract.h.html'>queue_kernel_abstract.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> queue_base
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='queue_sort'></a>queue_sort</b> : <font color='#0000FF'>public</font> queue_base
    <b>{</b>

        <font color='#009900'>/*!
            REQUIREMENTS ON QUEUE_BASE
                - is an implementation of queue/queue_kernel_abstract.h
                - queue_base::type must be a type with that is comparable via operator&lt;

            POINTERS AND REFERENCES TO INTERNAL DATA
                sort() may invalidate pointers and references to internal data.

            WHAT THIS EXTENSION DOES FOR QUEUE
                This gives a queue the ability to sort its contents by calling sort().
        !*/</font>


        <font color='#0000FF'>public</font>:

            <font color='#0000FF'><u>void</u></font> <b><a name='sort'></a>sort</b> <font face='Lucida Console'>(</font>
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures
                    - for all elements in #*this the ith element is &lt;= the i+1 element
                    - #at_start() == true
                throws
                    - std::bad_alloc or any exception thrown by T's constructor
                        data may be lost if sort() throws
            !*/</font>

            <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> compare_type<font color='#5555FF'>&gt;</font>
            <font color='#0000FF'><u>void</u></font> <b><a name='sort'></a>sort</b> <font face='Lucida Console'>(</font>
                <font color='#0000FF'>const</font> compare_type<font color='#5555FF'>&amp;</font> compare
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures
                    - for all elements in #*this the ith element is &lt;= the i+1 element
                    - uses compare(a,b) as the &lt; operator.  So if compare(a,b) == true
                      then a comes before b in the resulting ordering.  
                    - #at_start() == true
                throws
                    - std::bad_alloc or any exception thrown by T's constructor
                        data may be lost if sort() throws
            !*/</font>
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>template</font> queue_base
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'><u>void</u></font> <b><a name='swap'></a>swap</b> <font face='Lucida Console'>(</font>
        queue_sort<font color='#5555FF'>&lt;</font>queue_base<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> a, 
        queue_sort<font color='#5555FF'>&lt;</font>queue_base<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> b 
    <font face='Lucida Console'>)</font> <b>{</b> a.<font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>b<font face='Lucida Console'>)</font>; <b>}</b>  
    <font color='#009900'>/*!
        provides a global swap function
    !*/</font>

<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_QUEUE_SORt_ABSTRACT_
</font>

</pre></body></html>